export class Cancle{
    constructor(public reason: string) { }
}

export function isCancle(err: any){
    return err instanceof Cancle;
}

export class CancleToken {
    public resolve: any;
    source(){
        return {
            token: new Promise((resolve) => {
                this.resolve = resolve;
            }),
            cancel: (reason: string) => {
                this.resolve(new Cancle(reason));
            }
        }
    }
}